var _util = require('util/util.js');

var _order_service = {
    setOrder : function(order,resolve,reject){
        _util.request({
            url     : _util.getServerURL("Order/orderSession"),
            method  : 'POST',
            data    : order,
            success : resolve,
            error   : reject,
        });
    },
    setShipOrder : function(order,resolve,reject){
        _util.request({
            url     : _util.getServerURL("Order/orderShipSession"),
            method  : 'POST',
            data    : order,
            success : resolve,
            error   : reject,
        });
    },
    getOrder : function(resolve,reject){
        _util.request({
            url     : _util.getServerURL("Order/oldOrder"),
            method  : 'GET',
            success : resolve,
            error   : reject,
        });
    },
    insertOrder : function(resolve,reject){
        _util.request({
            url     : _util.getServerURL("Order/newOrder"),
            method  : 'POST',
            success : resolve,
            error   : reject,
        });
    },
    selectOrder : function(resolve,reject){
        _util.request({
            url     : _util.getServerURL("Order/persistenceOrder"),
            method  : 'GET',
            success : resolve,
            error   : reject,
        });
    },
    payForOrder : function(totalPrice,orderId,orderName,orderDescrip,resolve,reject){
        _util.request({
            url     : _util.getServerURL("Order/pay/" + totalPrice +'/'+ orderId +'/' + orderName +'/' +orderDescrip),
            method  : 'GET',
            success : resolve,
            error   : reject,
        });
    }
}

module.exports = _order_service;